#include "recordconfig.h"

RecordConfig* RecordConfig::c = new RecordConfig;

RecordConfig *RecordConfig::config()
{
    return c;
}

void RecordConfig::setRecordDev(QString devName)
{
    setConfig("RecordDev", devName);
}

void RecordConfig::setMapFilePath(QString path)
{
    setConfig("MapFilePath", path);
}

QString RecordConfig::getRecordDev()
{
    return getConfig("RecordDev", QString()).toString();
}

QString RecordConfig::getMapFilePath()
{
    return getConfig("MapFilePath", qApp->applicationDirPath()).toString();
}

RecordConfig::RecordConfig(QObject *parent) : QObject(parent)
{
    settingsFile = "/record.ini";
}

void RecordConfig::setConfig(QString key, QVariant val)
{
    QSettings settings(qApp->applicationDirPath() + settingsFile, QSettings::IniFormat);
    settings.setValue(key, val);
    settings.sync();
}

QVariant RecordConfig::getConfig(QString key, QVariant defaultVal)
{
    QSettings settings(qApp->applicationDirPath() + settingsFile, QSettings::IniFormat);
    return settings.value(key, defaultVal);
}

